﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using opSysPower.Definition;


namespace opSysPower.IServices
{
    public interface IGraphicDocumentServices<T> 
    {
        T CurrentGraphicDocument { get; }

        void Load(T schematic);

        bool Save();

        bool Update();

        bool Delete();
    }
    public abstract class GraphicDocumentServices<T> : IGraphicDocumentServices<T> where T : IGraphicSchematic
    {
        private T _schematic;
        #region IGraphicDocumentServices<T> 成员

        public T CurrentGraphicDocument
        {
            get
            {
                if (_schematic != null) return _schematic;

                throw new ArgumentNullException("没有被馈线初始化，当前馈线为空");
            }
        }

        public void Load(T schematic)
        {
            _schematic = schematic;
        }

        public bool Save()
        {
            return _schematic.Save();
        }

        public bool Update()
        {
            return _schematic.Update();
        }

        public bool Delete()
        {
            return _schematic.Delete();
        }

        #endregion
    }


    public interface ISchematicDocumentService : IGraphicDocumentServices<ISchematic>
    {


    }

    [Export(typeof(ISchematicDocumentService))]
    public class SchematicDocumentService : GraphicDocumentServices<ISchematic>,ISchematicDocumentService
    {
        
      

    }
}
